import { HTMLElement } from 'node-html-parser';

export default function get_nodes_by_tagname_or_id(no: string, dom_node: HTMLElement) {
	const node_list = dom_node.querySelectorAll(no) as HTMLElement[];
	if (node_list && node_list.length > 0) {
		return node_list;
	} else {
		// todo 兼容之前代码，需在框架版本4.2时移除
		const node = dom_node.querySelector(`#${no}`) as HTMLElement;
		if (!node) {
			throw new Error(`Could not find node: ${no}`);
		} else {
			return [node];
		}
	}
}
